package com.uuah.server.context.notification;

import com.uuah.server.api.component.service.IService;

/**
 * <code>ServiceNotification</code> is fired when an event such as the service
 * starting occurs. The payload of this event will always be a reference to the
 * service.
 *
 * <p>
 * update record:updator，update time，update content and version
 * </p>
 *
 * @author <a href="jonny_quan@hotmail.com">jonny</a>
 * @date 2009 2009-3-27 下午01:34:27
 * @version 1.0.0
 */
public class ServiceNotification extends ServerNotification {
	private static final long serialVersionUID = -8575741816897936674L;
	public static final int SERVICE_INITIALISED = SERVICE_EVENT_ACTION_START_RANGE + 1;
	public static final int SERVICE_STARTED = SERVICE_EVENT_ACTION_START_RANGE + 2;
	public static final int SERVICE_STOPPED = SERVICE_EVENT_ACTION_START_RANGE + 3;
	public static final int SERVICE_PAUSED = SERVICE_EVENT_ACTION_START_RANGE + 4;
	public static final int SERVICE_RESUMED = SERVICE_EVENT_ACTION_START_RANGE + 5;
	public static final int SERVICE_DISPOSED = SERVICE_EVENT_ACTION_START_RANGE + 6;
	public static final int SERVICE_STOPPING = SERVICE_EVENT_ACTION_START_RANGE + 7;

	static {
		registerAction("service initialised", SERVICE_INITIALISED);
		registerAction("service started", SERVICE_STARTED);
		registerAction("service stopping", SERVICE_STOPPING);
		registerAction("service stopped", SERVICE_STOPPED);
		registerAction("service paused", SERVICE_PAUSED);
		registerAction("service resumed", SERVICE_RESUMED);
		registerAction("service disposed", SERVICE_DISPOSED);
	}

	public ServiceNotification(IService message, int action) {
		super(message, action);
		resourceIdentifier = message.getName();
	}

	protected String getPayloadToString() {
		return ((IService) source).getName();
	}
}
